home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
qbtools1.arc
/
AEINPNUM.BAS
< prev
next >
Wrap
BASIC Source File
|
1987-01-12
|
4KB
|
169 lines
rem $linesize:132
rem $title:'Application Engineer Standard Routines'
rem $subtitle:'Get numeric with range validation'
'
' Input.Numeric
' Sub Routine to allow numeric input
' Uses calls to basic building block routines.
' Ver 1.0 , Dec-21-1986
'
' Ver 1.1 , Jan-12-1987
' Change: If the initial value is zero, then the string should have a
' null length. Otherwise ESC has to be pressed. Silly.
'
' Include the COMMON values
rem $include:'AESHARED.BAS'
sub Input.Numeric (ycoord%,xcoord%,nva#,minv#,maxv#,bdec%,decm%,help%) static
' ycoord% = Y co-ordinate
' xcoord% = X co-ordinate
' nva# = numeric value
' minv# = minimum input value allowed
' maxv# = maximum input value allowed
' bdec% = length of input before decimals
' decm% = decimal places allowed
' help% = help text number
lngth%=bdec%+decm%+abs(bdec%>0% and decm%>0%)
long.flip%=0%
vloop%=0%
im$=""
if bdec% then
im$=string$(bdec%,"#")
end if
if decm% then
if bdec% then
im$=im$+"."
end if
im$=im$+string$(decm%,"#")
end if
stg$=mid$(str$(nva#),2%)
if nva#=0# then ' If value is Zero, make it a NULL
stg$=""
end if
call decimal.check(stg$,before%,after%)
while vloop%=0%
call decimal.check(stg$,before%,after%)
loop%=0%
prefix.d%=before% ' Pre decimal
postfix.d%=after% ' Post decimal
while loop%=0%
if len(stg$)<lngth% then
if long.flip%=1% then
locate 25,1,0
call clreol
long.flip%=0%
end if
end if
call qprint (stg$+string$(lngth%-len(stg$),32),ycoord%,xcoord%)
xd%=xcoord%+len(stg$)
locate ycoord%,xd%,1,0,15
call Get.Character.Type(a$,schr%,2%)
if len(a$)=0% then ' ESCape - clear input line.
stg$=""
schr%=2%
end if
if schr%=0% then
if len(stg$)=lngth% then
if long.flip%=0% then
locate 25,1,0
call clreol
beep
es$="Warning 1, maximum of"+str$(lngth%)+" characters already reached."
call qprint(es$,25%,1%)
long.flip%=1%
end if
end if
if len(stg$)<lngth% then
if a$="." then
if decm% then
if prefix.d%=len(stg$) then
stg$=stg$+a$
end if
end if
end if
if a$<>"." then
if postfix.d%=0% then
stg$=stg$+a$
a$=""
end if
if postfix.d%<>0% then
if postfix.d%<decm% then
stg$=stg$+a$
a$=""
end if
end if
if prefix.d%<>0% then
if postfix.d%=0% then
if prefix.d%<bdec% then
stg$=stg$+a$
a$=""
end if
end if
end if
end if
end if
end if
if schr%=1% then
chk%=asc(a$)
if chk%=6% then
if len(stg$) then
if len(stg$)=1 then
stg$=""
postfix.d%=0%
prefix.d%=0%
end if
if len(stg$) then
stg$=mid$(stg$,1,len(stg$)-1)
end if
end if
end if
if chk%=0% then
loop%=1%
end if
end if
call decimal.check(stg$,prefix.d%,postfix.d%)
call zero.check(prefix.d%)
call zero.check(postfix.d%)
wend
nva#=val(stg$)
if nva#=<maxv# and nva#>=minv# then
vloop%=1%
locate ycoord%,xcoord%
print using im$;nva#;
else
locate 25,1,0
call clreol
em$="Warning 2, allowable ranges are = or >"+str$(minv#)+" and = or <"+str$(maxv#)
call qprint(em$,25,1)
end if
wend
locate 25,1,0
call clreol
end sub